package goover.unit06;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
public class CallableDemo01 {
    public static void main(String[] args){
        Thread t1 = new Thread(new FutureTask<Object>(new Thread03()),"t1");
        t1.start();
        Thread t2 = new Thread(new FutureTask<Object>(new Thread03()),"t2");
        t2.start();
        FutureTask<Object> f1 = new FutureTask<>(new Thread03());
        new Thread(f1).start();
        try {
            System.out.println(f1.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}
class Thread03 implements Callable{
    @Override
    public Object call() throws Exception {
        int i = 0;
        while (i++ < 5){
            System.out.println(Thread.currentThread().getName());
        }
        return i;
    }
}